﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XWord.GUI.Presenters.Fundamental;
using Microsoft.Practices.ServiceLocation;
using XWord.GUI.Presenters.Interface;

namespace XWord.GUI
{
    public class WordFilter
    {
        public WordFilter()
        {
            _wordExplorerPresenter = ServiceLocator.Current.GetInstance<IWordExplorerPresenter>() as WordExplorerPresenter;
        }

        private WordExplorerPresenter _wordExplorerPresenter;

        public int FilerNoEtymaWordList()
        {
            _wordExplorerPresenter.WordList = _wordExplorerPresenter.EntityList
                .Where(e => string.IsNullOrEmpty(e.Value.Suffix)).Select(e => e.Key).OrderBy(e => e).ToList();
            return _wordExplorerPresenter.WordList.Count;
        }

        public int FilerNoFamilarWordList()
        {
            _wordExplorerPresenter.WordList = _wordExplorerPresenter.EntityList
                .Where(e => e.Value.IsFamiliar == false).Select(e => e.Key).OrderBy(e => e).ToList();
            return _wordExplorerPresenter.WordList.Count;
        }

        public int[] Statisic()
        {
            int[] counts = new int[] { 0, 0, 0 };
            counts[0] = _wordExplorerPresenter.EntityList.Count;
            counts[1] = _wordExplorerPresenter.EntityList
                .Count(e => e.Value.IsFamiliar == false);
            counts[2] = _wordExplorerPresenter.EntityList
                .Count(e => string.IsNullOrEmpty(e.Value.Suffix));
            return counts;
        }
    }
}
